/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cubelabs.nexus.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author chaitanya
 */
@Entity
public class Event extends BaseEntity{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long id;

	@ManyToOne
	public User organizer;
	
	public String description;
	
	public Date start = new Date();

    public Date end = new Date();

    private Integer minRequired;
    private Integer maxAllowed;
    private Boolean personalDataRequired;
    private Integer price=0;
    @OneToMany(mappedBy = "event")
    List<EventSubscription> eventSubscriptions;
	public List<EventSubscription> getEventSubscriptions() {
		return eventSubscriptions;
	}

	public void setEventSubscriptions(List<EventSubscription> eventSubscriptions) {
		this.eventSubscriptions = eventSubscriptions;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public User getOrganizer() {
		return organizer;
	}

	public void setOrganizer(User organizer) {
		this.organizer = organizer;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getStart() {
		return start;
	}

	public void setStart(Date start) {
		this.start = start;
	}

	public Date getEnd() {
		return end;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

    public Integer getMinRequired() {
        return minRequired;
    }

    public void setMinRequired(Integer minRequired) {
        this.minRequired = minRequired;
    }

    public Integer getMaxAllowed() {
        return maxAllowed;
    }

    public void setMaxAllowed(Integer maxAllowed) {
        this.maxAllowed = maxAllowed;
    }

    public Boolean getPersonalDataRequired() {
        return personalDataRequired;
    }

    public void setPersonalDataRequired(Boolean personalDataRequired) {
        this.personalDataRequired = personalDataRequired;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

	public boolean hasMoreSlots() {
		if(this.maxAllowed <= this.getEventSubscriptions().size()) {
			return false;
		}
		return true;
	}

}
